package com.tangdada.whacmole.base;

import java.util.HashMap;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;

public class SoundPoolManager {
    private SoundPool mSoundPool;
    private HashMap mSoundPoolMap;

    private Context mContext;

    public SoundPoolManager(Context theContext) {
        mContext = theContext;
        mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
        mSoundPoolMap = new HashMap<Integer, Integer>();
    }

    public void addSound(int index, int SoundID) {
        mSoundPoolMap.put(index, mSoundPool.load(mContext, SoundID, 1));
    }

    public void playSound(int index) {
        mSoundPool.play(((Integer) mSoundPoolMap.get(index)).intValue(), 1, 1, 1, 0, 1f);
    }

    public void release(){
        mSoundPool.release();
    }


}
